import Vue from '@vitejs/plugin-vue'
import path from 'path'
import { defineConfig } from 'vite'
function _resolve(dir) {
  return path.resolve(__dirname, dir)
}

export default defineConfig(({mode}) => {
  return {
    base: '/screen/',
    plugins: [
      Vue()
    ],
    resolve: {
      alias: {
        '@': _resolve('src')
      }
    },
    server: {
      port: 9090,
      proxy: {
        '^/api': {
          target: 'http://172.21.165.130:9086',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, '')
        }
      }
    },
    optimizeDeps: {
      force: true,
      esbuildOptions: {
        loader: {
          '.js': 'jsx'
        }
      }
    },
    css: {
      preprocessorOptions: {
        less: { javascriptEnabled: true }
      }
    }
  }
})
